from django.db import models
from django.contrib import admin
from redactor.fields import RedactorField
#from ckeditor.fields import RichTextField


# Create your models here.
class Article(models.Model):
    pic = models.ImageField(upload_to='image', max_length=255)
    title = models.CharField(max_length=100, verbose_name="标题")
    abstract = models.TextField(blank=True, null=True, verbose_name="摘要")
    tag = models.CharField(max_length=100, blank=True, verbose_name="标签")
    pub_time = models.DateTimeField(auto_now_add=True, verbose_name="发布时间")
    #content = models.TextField(blank=True, null=True, verbose_name="内容")
    content = RedactorField(verbose_name="内容")
    author = models.CharField(max_length=30, default="somebody call me monkey", verbose_name="作者")

    def __unicode__(self):
        return self.title

    class Meta:
        ordering = ['-pub_time']

class ArticleAdmin(admin.ModelAdmin):
    list_display = ('title', 'pub_time', 'author')
